package mao.thinkinjava.collection;

import java.util.*;

/**
 *
 * Integer的不可变性，
 */
public class TestConstructor {
    public static void main(String[] args) {
        LinkedHashSet<Integer> set = new LinkedHashSet<>();
        Integer a = new Integer(2);
        System.out.println(a.hashCode());
        set.add(a);
        List<Integer> list  = new ArrayList<>(set);
        Integer integer = list.get(0);
        System.out.println(integer.hashCode());
        System.out.println(list);//打印出来出任然是，{1,2}， integer = 3;其实已经指向了一个新的对象
        System.out.println(set.contains(3));
    }
}
